/**
 * 
 */
package sailing.managers.impl;

import java.util.List;

import cjlite.annotations.Inject;
import cjlite.utils.Lists;

import sailing.dao.BankNameDao;
import sailing.entity.BankName;
import sailing.managers.BankNameManager;

/**
 * @author ming
 * 
 */
public class BankNameManagerImpl implements BankNameManager {

	@Inject
	private BankNameDao bnDao;

	private List<BankName> bnList = Lists.newArrayList();


	/*
	 * (non-Javadoc)
	 * 
	 * @see sailing.managers.BankNameManager#isExist(java.lang.String)
	 */
	@Override
	public boolean isExist(String bankName) {
		for (BankName bn : bnList) {
			if (bn.getName().equals(bankName)) {
				return true;
			}
		}
		return false;
	}


	/*
	 * (non-Javadoc)
	 * 
	 * @see sailing.managers.BankNameManager#saveBankName(sailing.entity.BankName)
	 */
	@Override
	public boolean saveBankName(BankName bn) {
		return bnDao.save(bn);
	}


	/*
	 * (non-Javadoc)
	 * 
	 * @see sailing.managers.BankNameManager#getAllBankNameList()
	 */
	@Override
	public List<BankName> getAllBankNameList() {
		bnList.clear();
		bnList.addAll(bnDao.getAllList());
		return bnList;
	}


	/*
	 * (non-Javadoc)
	 * 
	 * @see sailing.managers.BankNameManager#isExist(sailing.entity.BankName)
	 */
	@Override
	public boolean isExist(BankName cc) {
		for (BankName bn : bnList) {
			if (bn.getName().equals(cc.getName()) && !bn.getId().equals(cc.getId())) {
				return true;
			}
		}
		return false;
	}


	/*
	 * (non-Javadoc)
	 * 
	 * @see sailing.managers.BankNameManager#updateBankName(sailing.entity.BankName)
	 */
	@Override
	public boolean updateBankName(BankName cc) {
		return bnDao.udpate(cc);
	}


	/*
	 * (non-Javadoc)
	 * 
	 * @see sailing.managers.BankNameManager#delete(sailing.entity.BankName)
	 */
	@Override
	public boolean delete(BankName cc) {
		return bnDao.delete(cc);
	}

}
